package server.handler.friendHandler;

import com.alibaba.fastjson.JSONObject;
import common.EnvelopeMessage;
import server.dao.FriendDao;
import server.handler.SimpleHandler;
import server.session.Session;

public class FriendResponseHandler implements SimpleHandler {
    @Override
    public void handle(EnvelopeMessage msg, Session session) {
        JSONObject body = msg.getBody();
        Integer fromId = body.getInteger("fromId");
        Integer toId = body.getInteger("toId");
        Boolean accept = body.getBoolean("accept");
        if (accept){
            new FriendDao().upDateFriend(fromId,toId,1);

        } else {
            new FriendDao().upDateFriend(fromId,toId,-1);
        }
    }
}
